﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
//using LTP.Accounts.Bus;
namespace HospitalManagement.Web.PatientInfo
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtFullName.Text.Trim().Length==0)
			{
                strErr += "病人姓名不能为空！\\n";	
			}
			if(this.txtAnonymousName.Text.Trim().Length==0)
			{
                strErr += "换用名不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtBirthday.Text))
			{
                strErr += "出生日期格式错误！\\n";	
			}
			if(this.txtBirthPlace.Text.Trim().Length==0)
			{
                strErr += "出生地不能为空！\\n";	
			}
			if(this.txtAddress.Text.Trim().Length==0)
			{
                strErr += "常住地址不能为空！\\n";	
			}
			if(this.txtMobile.Text.Trim().Length==0)
			{
                strErr += "手机号不能为空！\\n";	
			}
			if(this.txtPhone.Text.Trim().Length==0)
			{
                strErr += "固定电话不能为空！\\n";	
			}
			if(this.txtEmail.Text.Trim().Length==0)
			{
                strErr += "电子邮箱不能为空！\\n";	
			}
			if(this.txtContact.Text.Trim().Length==0)
			{
                strErr += "联系人不能为空！\\n";	
			}
			if(this.txtRelation.Text.Trim().Length==0)
			{
                strErr += "关系不能为空！\\n";	
			}
			if(this.txtSurvival.Text.Trim().Length==0)
			{
                strErr += "生存情况不能为空！\\n";	
			}
			if(this.txtSick.Text.Trim().Length==0)
			{
                strErr += "有无病情进展不能为空！\\n";	
			}
			if(this.txtprogressionTime.Text.Trim().Length==0)
			{
                strErr += "进展时间不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtComeInTime.Text))
			{
                strErr += "入院时间格式错误！\\n";	
			}
            //if(!PageValidate.IsNumber(txtDisabled.Text))
            //{
            //    strErr+="Disabled格式错误！\\n";	
            //}
            //if(!PageValidate.IsDateTime(txtIndate.Text))
            //{
            //    strErr+="Indate格式错误！\\n";	
            //}
            //if(this.txtInUser.Text.Trim().Length==0)
            //{
            //    strErr+="InUser不能为空！\\n";	
            //}
            //if(!PageValidate.IsDateTime(txtEditDate.Text))
            //{
            //    strErr+="EditDate格式错误！\\n";	
            //}
            //if(this.txtEditUser.Text.Trim().Length==0)
            //{
            //    strErr+="EditUser不能为空！\\n";	
            //}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string FullName=this.txtFullName.Text;
			string AnonymousName=this.txtAnonymousName.Text;
			DateTime Birthday=DateTime.Parse(this.txtBirthday.Text);
			string BirthPlace=this.txtBirthPlace.Text;
			string Address=this.txtAddress.Text;
			string Mobile=this.txtMobile.Text;
			string Phone=this.txtPhone.Text;
			string Email=this.txtEmail.Text;
			string Contact=this.txtContact.Text;
			string Relation=this.txtRelation.Text;
			string Survival=this.txtSurvival.Text;
			string Sick=this.txtSick.Text;
			string progressionTime=this.txtprogressionTime.Text;
			DateTime ComeInTime=DateTime.Parse(this.txtComeInTime.Text);
            int Disabled = 0;// int.Parse(this.txtDisabled.Text);
            DateTime Indate = DateTime.Now;//DateTime.Parse(this.txtIndate.Text);
            string InUser = "System";//this.txtInUser.Text;
			//DateTime EditDate=DateTime.Parse(this.txtEditDate.Text);
			//string EditUser=this.txtEditUser.Text;

			HospitalManagement.Model.PatientInfo model=new HospitalManagement.Model.PatientInfo();
			model.FullName=FullName;
			model.AnonymousName=AnonymousName;
			model.Birthday=Birthday;
			model.BirthPlace=BirthPlace;
			model.Address=Address;
			model.Mobile=Mobile;
			model.Phone=Phone;
			model.Email=Email;
			model.Contact=Contact;
			model.Relation=Relation;
			model.Survival=Survival;
			model.Sick=Sick;
			model.progressionTime=progressionTime;
			model.ComeInTime=ComeInTime;
			model.Disabled=Disabled;
			model.Indate=Indate;
			model.InUser=InUser;
            model.EditDate = null;// EditDate;
            model.EditUser = null;// EditUser;

			HospitalManagement.BLL.PatientInfo bll=new HospitalManagement.BLL.PatientInfo();
			bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "../PatientInfo/add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("../PatientInfo/list.aspx");
        }
    }
}
